﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using RooHui.Infrastructure.Entities.EFContext;
using RooHui.Infrastructure.Entities.Repository;
using RooHui.Infrastructure.Entities.Enum;

namespace RooHui.Infrastructure.Entities.Entity
{
    public class AgentInfo : IAccessible<P_AgentInfo, AgentInfo>, ILogicEntity<P_AgentInfo, AgentInfo>
    {
        public string UserName { get; set; }
        public string AgentCode { get; set; }
        public SettlementType SettlementType { get; set; }
        public decimal Settlement { get; set; }


        protected override void Covariant(P_AgentInfo model)
        {
            if (model != null)
            {
                this.UserName = model.UserName;
                this.AgentCode = model.AgentCode;
                this.SettlementType = (Enum.SettlementType)model.SettlementType;
                this.Settlement = model.Settlement;
            }
        }

        protected override P_AgentInfo Inverter(AgentInfo model)
        {
            if (model != null)
            {
                return new P_AgentInfo()
                {
                    AgentCode = model.AgentCode,
                    Settlement = model.Settlement,
                    SettlementType = (int)model.SettlementType,
                    UserName = model.UserName
                };
            }
            return null;
        }

        public AgentInfo Set(P_AgentInfo dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
